package com.yuanhua.rabbitmq.workqueue;

import com.alibaba.fastjson.JSON;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.yuanhua.rabbitmq.utils.RabbitConstant;
import com.yuanhua.rabbitmq.utils.RabbitUtils;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/*
订单发送者
 */
public class OrderSystem {
    public static void main(String[] args) throws IOException, TimeoutException {
        Connection connection = RabbitUtils.getConnection();
        Channel channel = connection.createChannel();
        channel.queueDeclare(RabbitConstant.QUEUE_SMS, false, false,false,null);

        for (int i = 0; i < 100; i++) {
            SMS sms = new SMS("乘客" + i, "152356236" + i, "车票预定成功");
            String s = JSON.toJSONString(sms);
            channel.basicPublish("", RabbitConstant.QUEUE_SMS, null, s.getBytes());

        }
        System.out.println("数据发送成功");
        channel.close();
        connection.close();
    }
}
